Hello World

"""
This script uses a decorated cron rule that will generate logs every 10s and can be used to test your initial setup.
"""

from core.rules import rule
from core.triggers import when

@rule("Jython Hello World (cron decorators)", description="This is an example cron triggered rule using decorators", tags=["Test tag", "Hello World"])# description and tags are optional
@when("Time cron 0/10 * * * * ?")
def hello_world_cron_decorators(event):
    hello_world_cron_decorators.log.info("Hello World!")
'use strict';

var OPENHAB_CONF = Java.type("java.lang.System").getenv("OPENHAB_CONF");
load(OPENHAB_CONF+'/automation/lib/javascript/core/rules.js');
var me = "HelloWorld.js";

JSRule({
    name: "Javascript Hello World (GenericCronTrigger raw API with JS helper libraries)",
    description: "This is an example Jython cron rule using the raw API",
    triggers: [
        TimerTrigger("0/10 * * * * ?")
    ],
    execute: function( module, inputs){
        logInfo("Hello World!");
    }
});
import org.slf4j.LoggerFactory

def log = LoggerFactory.getLogger("jsr223.groovy")

import org.openhab.core.automation.Action
import org.openhab.core.automation.module.script.rulesupport.shared.simple.SimpleRule
import org.eclipse.smarthome.config.core.Configuration

scriptExtension.importPreset("RuleSupport")

def rawAPIRule = new SimpleRule() {
    String name = "Groovy Hello World (GenericCronTrigger raw API)"
    String description = "This is an example Hello World rule using the raw API"
    Object execute(Action module, Map<String, ?> inputs) {
        log.info("Hello World!")
    }
}

rawAPIRule.setTriggers([
    TriggerBuilder.create()
        .withId("aTimerTrigger")
        .withTypeUID("timer.GenericCronTrigger")
        .withConfiguration(new Configuration([cronExpression: "0/10 * * * * ?"]))
        .build()
    ])
    
automationManager.addRule(rawAPIRule)